<%@ page language="java" errorPage="/WEB-INF/common/exception.jsp" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<%@ include file="/WEB-INF/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>系统用户管理</title>
<script type="text/javascript">
$(document).ready(function(){
	var id = $("input[type='hidden'][name='vo.id']").val();
	if($.trim(id)!=""){
		$("input[type='text'][name='vo.username']").attr("disabled",true);
	}
});

function ajaxCheckCode(){
	var username =$("input[type='text'][name='vo.username']").val();
	var id = $("input[type='hidden'][name='vo.id']").val();
	if($.trim(username)!=""){
		$.ajax({
	        type:"post",
	        url:"<c:url value='/admin/system/sys-user/ajaxCheckCode.json' />",
	        cache:false,
	        data:{"vo.id":id,"vo.username":username,"rnd":Math.random()},
	        dataType:"json",
			success:function(msg){
				var obj = eval(msg);
				if(obj.isok){
					$("#msgFont").text("该用户名可以使用");
				}else{
					$("#msgFont").text("该用户名已经添加");
				}
	        }
		});
	}
}
</script>
</head>
<body>
<div class="main">
    <div class="subTitle">
        <h2><strong>系统用户管理</strong></h2>
    </div>
	<h3 class="subBoxTitle mT5"><c:if test="${empty id}">添&nbsp;&nbsp;&nbsp;&nbsp;加</c:if><c:if test="${not empty id}">修&nbsp;&nbsp;&nbsp;&nbsp;改</c:if></h3>
	<form name="form1" action="<c:url value='/admin/system/sys-user/save.jhtml' />" method="post" onsubmit="return Validator.Validate(this,3);">
		<div class="ntable_mid mT10" >
	        <table width="100%" class="nt_table">
	            <tr>
	                <td width="80" class="gray" height="40" align="right" ><font color="red">*</font>用户名：</td>
	                <td width="25%"><input name="vo.username" type="text" class="ntext_01" value="${vo.username }" size="30" onblur="ajaxCheckCode()" dataType="Require" msg="请输入代码" /><font id="msgFont" color="red"></font></td>
	                <td width="80" class="gray" height="40" align="right" >密码：</td>
	                <td colspan="3"><input name="vo.password" type="password" class="ntext_01" value="" size="30" /></td>
	            </tr>
	            <tr>
	                <td width="80" class="gray" height="40" align="right" ><font color="red">*</font>角色：</td>
	                <td width="25%"  colspan="5">
	                	<c:forEach var="sysRole" items="${roleList}">
	                		<c:set var="checked" value="0"></c:set>
	                		<c:forEach var="sysRoleUser" items="${roleUserList}">
	                			<c:if test="${sysRole.id==sysRoleUser.role.id}">
		                			<c:set var="checked" value="1" />
	                			</c:if>
	                		</c:forEach>
	               			<label><input name="ids" type="checkbox" value="${sysRole.id }" <c:if test="${checked==1}">checked="checked"</c:if>/>${sysRole.name }</label>&nbsp;&nbsp;
	                	</c:forEach>
	                </td>
	            </tr>
	        </table>
	    </div>
	    
		<div class="nbot_control mT10">
			<input type="hidden" name="vo.id" value="${vo.id}" />
			<input type="hidden" name="vo.sort" value="MANAGE" />
	        <input id="save" type="submit" class="formBtn01" value="保 存" />&nbsp;&nbsp;&nbsp;&nbsp;
	        <input id="back" type="button" class="formBtn02" value="关 闭" onclick="window.parent.window.$.weeboxs.close();" />
			<!-- <input id="back" type="button" class="formBtn02" value="返 回"  onclick="location.href='<c:url value='/admin/system/sys-user/index.jhtml' />';" /> -->
	    </div>
	</form>
</div>
</body>
</html>

